//动态数组vector
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char const *argv[])
{
    vector<int> v;

    cout << "capacity:" << v.capacity() << endl;
    cout << "size:" << v.size() << endl;

    v.push_back(1);
    v.push_back(2);
    v.push_back(3);

    cout << "capacity:" << v.capacity() << endl;//以2的n次幂增加，以增强系统内存利用率
    cout << "size:" << v.size() << endl;

    for(int i = 0; i < v.size(); i++)
    {
        cout << v[i] << " ";
    }

    cout << endl;

    vector<int> v2 = {1,2,3,4,5};
    
    v2.push_back(6);
    //v2.push_back(7);
    //v2.push_back(8);
    //v2.push_back(9);
    //v2.push_back(10);
    //v2.shrink_to_fit();

    cout << "capacity:" << v2.capacity() << endl;//以2的n次幂增加，以增强系统内存利用率
    cout << "size:" << v2.size() << endl;

    return 0;
}
